package dao;

import dao.Entity.Reservation;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class Query_one {

    public static Reservation getResult(int i) {
        MyConnection myCon = new MyConnection();
        myCon.getConnection();
        Reservation reservation = null;
        try {
            PreparedStatement ps = myCon.connection.prepareStatement(
                    "SELECT * FROM appointment where AppointmentNumber=?;");
            ps.setInt(1, i);
            ResultSet rs = ps.executeQuery();

            while (rs.next()) {
                reservation = new Reservation(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getInt(5), rs.getString(6), rs.getString(7));
            }
            ps.close();

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            myCon.closeConnection();
        }
        return reservation;
    }
}
